<?php
$oldfile = fopen("specialgrh1.php", "r") or exit("Unable to open file!");
$newfile = fopen("specialgrh1_name.php", 'w') or die("can't open file");
$newname = $_GET['newnametxt'];
//Output a line of the file until the end is reached
  $tmp ="graph->title->Set(\"";
//echo "new name is $newname<br>";
while(!feof($oldfile))
{	$line=fgets($oldfile);
  if(strpos($line,$tmp)){
	$Data="\$graph->title->Set('$newname');";
	fwrite($newfile, $Data);

  }
  else{
	$Data=$line;
		fwrite($newfile, $Data);

	//echo $line;
	
  }
}
fclose($oldfile);
fclose($newfile);
$myFile = "./jpgraph_cache/specialgrh1_name.png";
    if(file_exists($myFile)){
    unlink($myFile);
   }

//echo "<img src=\"http://localhost/test/graph/specialgrh1_name.php\">";
echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1_name.php\">";
//echo "<br><br><a href=\"http://localhost/test/graph/jpgraph_cache/specialgrh1_name.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";
echo "<br><br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1_name.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";


?> 